<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维保项目合同列表')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/Test.css">
</head>
<body class="gray-bg animated fadeInRight" style="background: white;">
     <div class="container-div">
         <div class="detail" style="margin-bottom: 10px; margin-top:15px;">
             <a class="btn btn-info btn-outline visible-xs-block" href="#" onclick="$.modal.closeTab()">返回</a>
             <nav class="nav" style="font-size: 15px; box-shadow: 0px 0px 0px 1px black;">
                 <a href="#" class="nav-item" active-color="orange" id="detail">详情</a>
                 <a href="#" class="nav-item" active-color="rebeccapurple" id="sheet">报告书联系单</a>
                 <a href="#" class="nav-item" active-color="rebeccapurple" id="engineers">维修工程</a>
                 <a href="#" class="nav-item" active-color="rebeccapurple" id="contact" style="color: black">维保项目合同</a>
             </nav>
         </div>
        <div class="row">
            <form id="formId" th:object="${mtId}" >
                <!-- <input name="bId" th:field="*{bId}" type="hidden">-->
            </form>
            <div class="col-sm-12 search-collapse" style="display: none">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>合同名称：</label>
                                <input type="text" name="mtContractName"/>
                            </li>
<!--                            <li>-->
<!--                                <label>维保合同上传：</label>-->
<!--                                <input type="text" name="mtContractUpload"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费用金额：</label>-->
<!--                                <input type="text" name="mtPrice"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>付款方式：</label>-->
<!--                                <input type="text" name="mtPayMethod"/>-->
<!--                            </li>-->
<!--                            <li class="select-time">-->
<!--                                <label>维保合同起始日期：</label>-->
<!--                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginMtContractDate]"/>-->
<!--                                <span>-</span>-->
<!--                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endMtContractDate]"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费发票是/否开具：</label>-->
<!--                                <select name="mtInvoiceStatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费发票是/否送至甲方并签收：</label>-->
<!--                                <input type="text" name="mtInvoiceSignfor"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费发票上传：</label>-->
<!--                                <input type="text" name="mtInvoiceUpload"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>伪外键：</label>-->
<!--                                <input type="text" name="mtId"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add(mtId)" shiro:hasPermission="ruoyi:contact:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:contact:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:contact:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel(mtId)" shiro:hasPermission="ruoyi:contact:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:contact:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:contact:remove')}]];
        var prefix = ctx + "ruoyi/contact";
        var mtId=[[*{mtId}]];
        var mtInvoiceStatus = [[${@dict.getType('invoice_status')}]];
        var mtInvoiceSignfor = [[${@dict.getType('signfor_status')}]];
        //详情
        $("#detail").click(function () {
            location.href="/ruoyi/build/detail/" + mtId
        });
        //报告书联系单
        $("#sheet").click(function () {
            location.href= "/ruoyi/sheet/sheet/" + mtId;
        });
        //维修工程
        $("#engineers").click(function () {
            location.href="/ruoyi/engineers/engineers/" + mtId
        });
        //维保项目合同
        $("#contact").click(function () {
            location.href="/ruoyi/contact/contact/" + mtId
        });
        $(function() {
            var options = {
                url: prefix + "/lists/"+mtId,
                createUrl: prefix + "/add/"+mtId,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export/"+mtId,
                modalName: "维保项目合同",
                showColumns: false,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'mtContractId',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'mtContractName',
                    title: '合同名称'
                },
                {
                    // field: 'mtPrice',
                    title: '费用金额',
                    formatter: function(value, row, index) {
                        var mtPrice = [];
                        mtPrice.push('￥'+ row.mtPrice);
                        return mtPrice.join('');
                    }
                },
                {
                    field: 'mtPayMethod',
                    title: '付款方式'
                },
                {
                    field: 'mtContractDate',
                    title: '合同起始日期'
                },
                    {
                        field: 'mtContractUpload',
                        title: '下载合同',
                        align: 'center',
                        formatter: function(value, row, index) {
                            return '<a href="javascript:downloadFile(\''+row.mtContractUpload+'\')">下载</a>';
                        },
                    },
                {
                    field: 'mtInvoiceStatus',
                    title: '发票开具',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mtInvoiceStatus, value);
                    }
                },
                {
                    field: 'mtInvoiceSignfor',
                    title: '发票签收',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mtInvoiceSignfor, value);
                    }
                },
                {
                    field: 'mtInvoiceUpload',
                    title: '签收证明',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.mtInvoiceUpload==null){
                            actions.push('未上传');
                            return actions.join('');
                        }else{
                            return '<a href="javascript:downloadFile(\''+row.mtInvoiceUpload+'\')">下载</a>';
                        }
                    },
                },
                {
                    field: 'mtId',
                    title: '伪外键',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.mtInvoiceSignfor==0||row.mtInvoiceUpload==null) {
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mtContractId + '\')"><i class="fa fa-edit"></i>维保项目金额</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mtContractId + '\')"><i class="fa fa-edit"></i>上传签收证据</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mtContractId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.mtInvoiceSignfor==1){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mtContractId + '\')"><i class="fa fa-edit"></i>维保项目金额</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mtContractId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function downloadFile(pUploading) {
            window.location.href=ctx+"common/download/resource?resource="+pUploading;
        }


        function clickss(mtContractId) {
            var urls = ctx + "ruoyi/price/price/"+mtContractId;
            $.modal.openTab("维保项目金额",urls);
        }
    </script>
</body>
</html>